package cn.com.pg.b2b.pd.truck.appointment.management.service.api;


import cn.com.pg.b2b.pd.truck.appointment.management.service.model.dto.LineStepDTO;
import cn.com.pg.b2b.pd.truck.appointment.management.service.service.LineStepService;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>
 * 线路节点 前端控制器
 * </p>
 *
 * @author 王开琦
 * @since 2023-06-08
 */
@Controller
@RequestMapping("/lineStep")
public class LineStepController {
    private final LineStepService lineStepService;

    public LineStepController(LineStepService lineStepService) {
        this.lineStepService = lineStepService;
    }

    /**
     * <h2>新增线路节点</h2>
     *
     * @param lineStepDTO
     */
    @PostMapping("add")
    public ResponseEntity<Void> add(@RequestBody LineStepDTO lineStepDTO) {
        lineStepService.add(lineStepDTO);
        return ResponseEntity.ok().build();
    }

    /**
     * <h2>根据ids删除路线节点</h2>
     *
     * @param lineStepIds
     */
    @PostMapping("delete")
    public ResponseEntity<Void> deleteByLineStepIds(@RequestBody List<Integer> lineStepIds) {
        lineStepService.deleteByLineStepIds(lineStepIds);
        return ResponseEntity.ok().build();
    }

    /**
     * <h2>修改线路节点</h2>
     *
     */
    @PostMapping("update")
    public ResponseEntity<Void> update(@RequestBody LineStepDTO lineStepDTO) {
        lineStepService.update(lineStepDTO);
        return ResponseEntity.ok().build();
    }

    /**
     * <h2>根据 lineStepIds 查询线路节点</h2>
     *
     */
    @PostMapping("getByLineStepIds")
    public ResponseEntity<List<LineStepDTO>> getByLineStepIds(@RequestBody List<Integer> lineStepIds) {
        return ResponseEntity.ok(lineStepService.getByLineStepIds(lineStepIds));
    }
    /**
     * <h2>根据 lineId 查询线路节点</h2>
     */
    public ResponseEntity<List<LineStepDTO>> getByLineId(@RequestParam Integer lineId) {
        return ResponseEntity.ok(lineStepService.getByLineId(lineId));
    }
}

